<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改大屏元素')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-userModel-edit" th:object="${visualModule}" >
        <input id="id" name="id" class="form-control" type="hidden" th:field="*{id}" required>

        <h3 class="form-header h3">大屏元素修改：</h3>


        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label ">数据大屏：</label>
                    <div class="col-sm-5">
                        <!--disabled="disabled" 只读效果-->
                        <select disabled="disabled" id="baseId" class="form-control" th:field="*{baseId}" th:with="type=${userVisualBases}" th:name="typeId">
                            <option value="">--选择数据大屏--</option>
                            <option
                                    th:each="dict : ${type}"
                                    th:selected="${baseId eq dict.id}"
                                    th:text="${dict.visualName}"
                                    th:value="${dict.id}">
                            </option>
                        </select>
                    </div>
                </div>
            </div>
        </div>





        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">SQL语句：</label>
                    <div class="col-sm-7">
                        <!--readonly="readonly"-->
                        <textarea th:field="*{sql}" cols="20" rows="10" id="sql" name="sql" class="form-control" required></textarea>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">API地址：</label>
                    <div class="col-sm-7">
                        <textarea th:field="*{apiUrl}" cols="20" rows="10" id="apiUrl" name="apiUrl" class="form-control" required></textarea>
                    </div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-3">
                <div th:object="${user}">
                    <input th:field="*{loginName}" class="form-control" readonly="readonly" type="hidden" name="updateUser"/>
                </div>
            </div>
        </div>

        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭</button>
        </div>

    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-select-js" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<script type="text/javascript">
    var prefix = ctx + "system/userModel";

    $("#form-userModel-edit").validate({
        onkeyup: false,
        onSubmit: true,
        focusCleanup: true
    });


    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $("#form-userModel-edit").serialize());
        }
    }

    // function submitHandler() {
    //     if ($.validate.form()) {
    //         var formData = new FormData($('#form-config-add')[0]);
    //         // formData.append('file', $('#file')[0].files[0]);
    //
    //         $.ajax({
    //             url: prefix + "/edit",
    //             type: 'post',
    //             cache: false,
    //             data: formData,
    //             processData: false,
    //             contentType: false,
    //             dataType: "json",
    //             success: function(result) {
    //                 $.operate.successCallback(result);
    //             }
    //         });
    //     }
    // }



</script>
</body>
</html>
